package com.wander.patterns.act.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: zhuyong
 * @create: 2019-09-11 17:06
 **/
public class Subject {
    List<Observer> list = new ArrayList<>();

    void addObserver(Observer o){
        list.add(o);
    }

    void removeObserver(Observer o){
        list.remove(o);
    }

    protected void notifyObservers(){
        for(Observer o: list){
            o.update(this);
        }
    }
}
